<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户登录</title>
    <!-- <link href="favicon.ico" rel="shortcut icon" /> -->
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style=" background: url(/static/img/bg01.png) no-repeat center center fixed; background-size: 100%;" onkeydown="keyLogin();">

    <div class="modal-dialog" style="margin-top:15%">
        <div class="modal-content" style="width:70%;hight:30%;margin: 0 auto;">
            <div class="modal-header" >
 
                <h4 class="modal-title text-center" id="myModalLabel">计算机人才招聘大数据可视化</h4>
            </div>
            <div class="modal-body" id = "model-body">
                <div class="form-group">
 
                    <input type="text" id="user" class="form-control"placeholder="用户名" autocomplete="off">
                </div>
                <div class="form-group">
 
                    <input type="password" id="password" class="form-control" placeholder="密码" autocomplete="off">
                </div>
            </div>
            <div class="modal-footer">
                <div class="form-group">
                    <button type="button"  id="login_button" onClick="login_check(document.getElementById('user').value,document.getElementById('password').value)" class="btn btn-primary form-control">登录</button>
                </div>
 
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
    <script type="text/javascript" src="/static/js/jquery-3.3.1.min.js"></script>
    <script>
      function login_check(user, password) {
          if(user==""){
            alert("请输入用户名!")
          }else if(password==""){
            alert("请输入密码!")
          }else{
            login_post(user,password)
          }
      }
      function login_post(user,password){
        var login_data = {}
		    login_data['user'] = user
        login_data['password'] = password
        // console.log(login_data)
        $.post("/main/login", data = login_data, result => {
            if(result["status"]==1){
              window.open("{{ url_for('ind.main')}}");
              alert("登录成功,正在跳转!")
            }
            else{
                <!-- 清空输入框-->
                $('#user').val('')
                $('#password').val('')
              alert("账号密码有误，请重新输入!")
            }
	    })
      }

      //绑定回车键事件
      function keyLogin(){
          if (event.keyCode==13) //回车键的键值为13
          document.getElementById("login_button").click(); //调用登录按钮的登录事件
      }
    </script>
</body>
</html>
